<template>
	<div style="width=200px">
		<el-form ref="form" :rules="rules" :model="form" label-width="200px">


			<el-form-item label="客户姓名" prop="username">
				<el-input v-model="form.username"></el-input>
			</el-form-item>
			<el-form-item label="外出事由" prop="goingOutReason">
				<el-input v-model="form.goingOutReason"></el-input>
			</el-form-item>
			
				<el-form-item label="外出时间" prop="goingOutTime">
					<span class="demonstration"></span>
					    <el-date-picker
					      v-model="form.goingOutTime "
					      type="date"
						  value-format="yyyy-MM-dd"
						  
					      placeholder="选择日期">时间
					    </el-date-picker>
					
				</el-form-item>
				<el-form-item label="预计回院时间" prop="estimatedTime">
					<span class="demonstration"></span>
					    <el-date-picker
					      v-model="form.estimatedTime "
					      type="date"
						  value-format="yyyy-MM-dd"
						  
					      placeholder="选择日期">时间
					    </el-date-picker>
					
				</el-form-item>
				
				
			</el-form-item>

			<el-form-item label="陪同人" prop="chaperone">
				<el-input v-model="form.chaperone"></el-input>
			</el-form-item>
			<el-form-item label="与老人关系" prop="relationship">
				<el-input v-model="form.relationship"></el-input>
			</el-form-item>
			<el-form-item label="陪同人电话" prop="chaperonePhone">
				<el-input v-model="form.chaperonePhone"></el-input>
			</el-form-item>
			
			<el-form-item label="审批状态" prop="status">
				
				 <el-select v-model="form.status" placeholder="请选择">
				    <el-option
				      v-for="item in options"
				      :key="item.value"
				      :label="item.label"
				      :value="item.label">
				 
				    </el-option>
				  </el-select>
			</el-form-item>
			
			
			<el-form-item label="审批人" prop="approver">
				<el-input v-model="form.approver"></el-input>
			</el-form-item>
			<el-form-item label="审批时间" prop="approvalTime">
				<span class="demonstration"></span>
				    <el-date-picker
				      v-model="form.approvalTime "
				      type="date"
					  value-format="yyyy-MM-dd"
					  
				      placeholder="选择日期">时间
				    </el-date-picker>
				
			</el-form-item>
			
		
			<el-form-item>
				<el-button type="primary" plain @click="save">保存数据</el-button>

			</el-form-item>
		</el-form>
		
	</div>
</template>

<script>
	export default {
		name: 'GoingOut',
		components: {

		},
		props: [
			'show',
			'editid'
		],
		data() {
			return {
				form: {
					username: '',
					gender: '',
					age: '',
					goingOutReason: '',
					goingOutTime: '',
					estimatedTime: '',
					chaperone: '',
					relationship: '',
					chaperonePhone: '',
					
					notes: '',
				},
				options: [{
				        value: '选项1',
				        label: '已审批'
				      }, {
				        value: '选项2',
				        label: '未审批'
				      }],
				rules: {

					name: [{
							required: true,
							message: '类别名不能为空',
							trigger: 'blur'
						},
						{
							min: 1,
							max: 100,
							message: '长度在 1 到 100 个字符',
							trigger: 'blur'
						}
					],
					
				},

				
				depts: [],
			}
		},
		
		
		created() {
			if (this.editid) {
				this.show = true;
				this.$axios.get(
					'goingOut/getById',
					response => {
						this.form = response.obj
						
					}, 
					{id: this.editid })
			}
		},
		methods: {
			save() {
				this.axios.get('/goingOut/add', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}

				}, this.form, '保存成功');
			},
			update(){
				this.axios.get('/goingOut/update', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}
				
				}, this.id,this.status,'更新成功');
				
			}
			
		}

	}
</script>

<style>
</style>
